<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  
  <style>
    
    * {
      margin: 0;
      padding: 0;
    }
    
    ul {
      list-style: none;
    }
    
    .wrap {
      width: 330px;
      height: 30px;
      margin: 100px auto 0;
      padding-left: 10px;
      background-image: url(images/bg.jpg);
    }
    
    .wrap li {
      background-image: url(images/libg.jpg);
    }
    
    .wrap > ul > li {
      float: left;
      margin-right: 10px;
      position: relative;
    }
    
    .wrap a {
      display: block;
      height: 30px;
      width: 100px;
      text-decoration: none;
      color: #000;
      line-height: 30px;
      text-align: center;
    }
    
    .wrap li ul {
      position: absolute;
      top: 30px;
      display: none;
    }
  
  </style>

</head>
<body>

<div class="wrap">
  <ul>
    <li>
      <a href="javascript:void(0);">一级菜单1</a>
      <ul>
        <li><a href="javascript:void(0);">二级菜单1</a></li>
        <li><a href="javascript:void(0);">二级菜单2</a></li>
        <li><a href="javascript:void(0);">二级菜单3</a></li>
      </ul>
    </li>
    <li>
      <a href="javascript:void(0);">一级菜单1</a>
      <ul>
        <li><a href="javascript:void(0);">二级菜单1</a></li>
        <li><a href="javascript:void(0);">二级菜单2</a></li>
        <li><a href="javascript:void(0);">二级菜单3</a></li>
      </ul>
    </li>
    <li>
      <a href="javascript:void(0);">一级菜单1</a>
      <ul>
        <li><a href="javascript:void(0);">二级菜单1</a></li>
        <li><a href="javascript:void(0);">二级菜单2</a></li>
        <li><a href="javascript:void(0);">二级菜单3</a></li>
      </ul>
    </li>
  </ul>
</div>

</body>
</html>

<script src="jq/jquery-1.12.2.js"></script>
<script>

  /**
   * 找到一级菜单
   *    注册鼠标移入事件，在事件处理程序里面找到子代ul，显示出来
   *    给一级菜单注册鼠标移出事件，处理程序里面找到子代ul，隐藏
   */

  $(function () {
    //找到索引的子代li并且注册鼠标移入事件
    $(".wrap>ul>li").mouseover(function () {
      //让这个元素的子代元素整个ul显示
      //在下一个动画执行前把前面的动画队列停止
      $(this).children("ul").stop().slideDown();
    });
    //找到索引的子代li并且注册鼠标移出事件
    $(".wrap>ul>li").mouseout(function () {
      //让这个元素的子代元素整个ul隐藏
      $(this).children("ul").stop().slideUp();
    });
  });


</script>